package chatgpt_api

import (
	"context"

	"github.com/openai/openai-go"
	"github.com/openai/openai-go/option"
)

const apiKey = ""

func NewClient() openai.Client {
	return openai.NewClient(
		option.WithAPIKey(apiKey), // defaults to os.LookupEnv("OPENAI_API_KEY")
	)
}

func SendMessage(ctx context.Context, cli openai.Client, req openai.ChatCompletionNewParams) (result string, err error) {
	chatCompletion, err := cli.Chat.Completions.New(ctx, req)
	if err != nil {
		return result, err
	}
	return chatCompletion.Choices[0].Message.Content, nil
}
